package com.rcdz.mykotlindemo

import androidx.collection.arraySetOf
import org.junit.Test

/**
 * for循环练习
 */
class ForExample {
    @Test
 fun Test(){
     //正序遍历
//     for (index in 1..100){
//         println(index)
//     }

     //倒序
//     for (index in 100 downTo 1){
//         println(index)
//     }
     //跳着走
//     for (index in 1..100 step 2){
//         println(index)
//     }
     //从0开始
//     for (index in 0 until 10){
//         println(index)
//     }
     //遍历一个数组
//     val array = arrayListOf("1","2","3")
//        for (index in 1..array.size){
//            println(index)
//        }

        //遍历一个数组 取出下标和元素
//     val array = arraySetOf("1","3","2","asda","asda1")
//        for ((index,e)in array.withIndex()){
//            println("index=="+index+"value==$e")
//        }
//
//        for (index in array){
//            println(index)
//        }

     //遍历一个数组只取下标
//     val array= arraySetOf<String>("1","3","2")
//        for (qw in array.indices){
//            println("index==$qw")
//        }
     //遍历一个数组 只取值
     val array = arraySetOf("1","3","2","asda")
        for (value in array){
            println("value== $value")
        }
 }
}